//
//  TXInterstitial.m
//  TestTX
//
//  Created by Akira on 2020/1/19.
//  Copyright © 2020 Akira. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GDTAction.h"
#import "GDTAction+convenience.h"

    /// <summary>
    /// 初始化
    /// </summary>
    /// <param name="actionSetID"></param>
    /// <param name="strSecretKey"></param>
    void InitGDTEvent(char * actionSetID, char * strSecretKey){
        printf("TXEvent::InitGDTEvent()");
        [GDTAction init:[NSString stringWithUTF8String:actionSetID] secretKey:[NSString stringWithUTF8String:strSecretKey]];
    }

    /// <summary>
    /// 通用上报
    /// </summary>
    /// <param name="strActionName">事件名</param>
    /// <param name="actionParam">事件值[key,value]</param>
    void LogAction(char * strActionName, void * pszJson){
        printf("TXEvent::LogAction()");
        NSString *strData=[NSString stringWithUTF8String:pszJson];
        NSArray *arrItem=[strData componentsSeparatedByString:@","];
        NSArray *arrKey=[NSArray array];
        NSArray *arrValue=[NSArray array];

        for(int i=0;i<arrItem.count;i++){
            if([arrItem[i] containsString:@":"]){
                NSArray *arrThem=[arrItem[i] componentsSeparatedByString:@":"];
                arrKey=[arrKey arrayByAddingObject:arrThem[0]];
                arrValue=[arrValue arrayByAddingObject:arrThem[1]];

            }
        }

        NSDictionary *dicParam = [NSDictionary dictionaryWithObjects:arrValue forKeys:arrKey];
        [GDTAction logAction:[NSString stringWithUTF8String:strActionName] actionParam:dicParam];
    }
    /// <summary>
    ///   @param method 表示注册方式，业务方可以传任意可标识注册方式的值，如注册方式为手机号：method = @"phone" 微信注册：method = @“WeChat” 邮箱：method = @"mail"等。这个参数作用：方便业务方在数据平台以method为key查询数据
    /// @param isSuccess 是否注册成功
    /// </summary>
    void reportRegisterActionWithMethod(char * strMethod, bool isSuccess){
        printf("TXEvent::reportRegisterActionWithMethod()");
        [GDTAction reportRegisterActionWithMethod:[NSString stringWithUTF8String:strMethod] isSuccess:isSuccess];
    }
    /// <summary>
    /// @param method 表示登录的方式，如游戏账号、手机号等
    /// @param isSuccess 是否登录成功
    /// </summary>
    void reportLoginActionWithMethod(char* strMethod, bool isSuccess){
        printf("TXEvent::reportLoginActionWithMethod()");
        [GDTAction reportLoginActionWithMethod:[NSString stringWithUTF8String:strMethod] isSuccess:isSuccess];
    }
    /// <summary>
    ///@param type 社交账号类型 如如微信、微博等
    ///@param isSuccess 是否绑定成功
    /// </summary>
    void reportBindSocialAccountActionWithType(char* strType, bool isSuccess){
        printf("TXEvent::reportBindSocialAccountActionWithType()");
        [GDTAction reportBindSocialAccountActionWithType:[NSString stringWithUTF8String:strType] isSuccess:isSuccess];
    }
    /// <summary>
    // @param questID 教学/任务/副本等关卡标识符
    // @param type 节点类型
    //@param name 教学/任务/副本等关卡名称
    //@param number 第几个任务节点
    //@param desc 节点描述
    //@param isSuccess 节点是否完成
    /// </summary>
    void reportFinishQuestActionWithQuestID(char *strQuestID, char* strQuestType, char* strQuestName, int iQuestNumber, char* strDesc, bool isSuccess){
        printf("TXEvent::reportFinishQuestActionWithQuestID()");
        [GDTAction reportFinishQuestActionWithQuestID:[NSString stringWithUTF8String:strQuestID] questType:[NSString stringWithUTF8String:strQuestType] questName:[NSString stringWithUTF8String:strQuestName] questNumer:iQuestNumber description:[NSString stringWithUTF8String:strDesc] isSuccess:isSuccess];
    }
    /// <summary>
    /// @param role 游戏角色
    /// </summary>
    void reportCreateRoleActionWithRole(char* strRole){
        printf("TXEvent::reportCreateRoleActionWithRole()");
        [GDTAction reportCreateRoleActionWithRole:[NSString stringWithUTF8String:strRole]];
    }
    /// <summary>
    /// @param level 当前用户等级
    /// </summary>
    void reportUpgradeLevelActionWithLevel(int iLevel){
        printf("TXEvent::reportUpgradeLevelActionWithLevel()");
        [GDTAction reportUpgradeLevelActionWithLevel:iLevel];
    }
    /// <summary>
    //@param type 内容类型如“配备”、“皮肤”
    //@param name 商品或内容名称
    //@param contentID 商品或内容标识符
    /// </summary>
    void reportViewContentActionWithContentType(char* strType, char* strName, char* strContentID){
        printf("TXEvent::reportViewContentActionWithContentType()");
        [GDTAction reportViewContentActionWithContentType:[NSString stringWithUTF8String:strType] contentName:[NSString stringWithUTF8String:strName] contentID:[NSString stringWithUTF8String:strContentID]];
    }
    /// <summary>

    //@param type 内容类型如“配备”、“皮肤”
    //@param name 商品或内容名称
    //@param contentID 商品或内容标识符
    //@param number 商品数量
    //@param isSuccess 加入购买/购物车是否成功
    /// </summary>
    void reportAddingToCartActionWithContentType(char* strType, char* strName, char* strContentID, int iNumber, bool isSuccess){
        printf("TXEvent::reportAddingToCartActionWithContentType()");
        [GDTAction reportAddingToCartActionWithContentType:[NSString stringWithUTF8String:strType] contentName:[NSString stringWithUTF8String:strName] contentID:[NSString stringWithUTF8String:strContentID] contentNumber:iNumber isSuccess:isSuccess];
    }
    /// <summary>
    //@param type 内容类型如“配备”、“皮肤"
    //@param name 商品或内容名称
    //@param contentID 商品或内容标识符
    //@param number 商品数量
    //@param isVirtualCurrency 是否使用的是虚拟货币
    //@param virtualCurrencyType 虚拟货币类型，如"元宝"、“金币”等
    //@param realCurrencyType 真实货币类型，ISO 4217代码，如：“USD”
    //@param isSuccess 提交购买/下单是否成功
    /// </summary>
    void reportCheckoutActionWithContentType(char* strType
        , char* strName
        , char* strContentID
        , int iNumber
        , bool isVirtualCurrency
        , char* strVirtualCurrencyType
        , char* strrealCurrencyType
        , bool isSuccess){
        printf("TXEvent::reportCheckoutActionWithContentType()");
        [GDTAction reportCheckoutActionWithContentType:[NSString stringWithUTF8String:strType] contentName:[NSString stringWithUTF8String:strName] contentID:[NSString stringWithUTF8String:strContentID] contentNumber:iNumber isVirtualCurrency:isVirtualCurrency virtualCurrencyType:[NSString stringWithUTF8String:strVirtualCurrencyType] realCurrencyType:[NSString stringWithUTF8String:strrealCurrencyType] isSuccess:isSuccess];
    }

    /// <summary>
    //@param type 内容类型如“配备”、“皮肤”
    //@param name 商品或内容名称
    //@param contentID 商品或内容标识符
    //@param number 商品数量
    //@param channel 支付渠道名，如支付宝、微信等
    //@param realCurrency 真实货币类型，ISO 4217代码，如：“USD”
    //@param amount 本次支付的真实货币的金额
    //@param isSuccess 支付是否成功
    /// </summary>
    void reportPurchaseActionWithContentType(char * strType
        , char* strName
        , char* strContentID
        , int iNumber
        , char* strChannel
        , char* strRealCurrencyType
        , int iAmount
        , bool isSuccess){
        printf("TXEvent::reportPurchaseActionWithContentType()");
        [GDTAction reportPurchaseActionWithContentType:[NSString stringWithUTF8String:strType] contentName:[NSString stringWithUTF8String:strName] contentID:[NSString stringWithUTF8String:strContentID] contentNumber:iNumber paymentChannel:[NSString stringWithUTF8String:strChannel] realCurrency:[NSString stringWithUTF8String:strRealCurrencyType] currencyAmount:iAmount isSuccess:isSuccess];
    }
    /// <summary>
    ///   @param channel 支付渠道名，如支付宝、微信支付等
    ///@param isSuccess 添加支付渠道是否成功
    /// </summary>
    void reportAddPaymentChannelActionWithChannel(char* strChannel, bool isSuccess){
        printf("TXEvent::reportAddPaymentChannelActionWithChannel()");
        [GDTAction reportAddPaymentChannelActionWithChannel:[NSString stringWithUTF8String:strChannel] isSuccess:isSuccess];
    }
    /// <summary>
    /// @param rate 评分
    /// </summary>
    void reportRateActionWithRate(float rate){
        printf("TXEvent::reportRateActionWithRate()");
        [GDTAction reportRateActionWithRate:rate];
    }
    /// <summary>
    /// 渠道分享
    /// </summary>
    void reportShareActionWithChannel(char* strChannel, bool isSuccess){
        printf("TXEvent::reportShareActionWithChannel()");
        [GDTAction reportShareActionWithChannel:[NSString stringWithUTF8String:strChannel] isSuccess:isSuccess];
    }
